# 数据类型转换

print("数据类型转换")

n1 = 1

n2 = 1.9

n3 = True

n4 = "1"
n5 = "1.0"
n6 = "张"

print("转int")
print(int(n1))  # 1
print(int(n2))  # 1
print(int(n3))  # 1
print(int(n4))  # 1
# print(int(n5))  # ValueError: invalid literal for int() with base 10: '1.0'
# print(int(n6))  # ValueError: invalid literal for int() with base 10: '张'

print("转float")
print(float(n1))  # 1.0
print(float(n2))  # 1.9
print(float(n3))  # 1.0
print(float(n4))  # 1.0
print(float(n5))  # 1.0
# print(float(n6))  # ValueError: could not convert string to float: '张'

print("转string")
print(str(n1))  # 1.0
print(str(n2))  # 1.9
print(str(n3))  # True
print(str(n4))  # 1
print(str(n5))  # 1.0
print(str(n6))  # 张
print(type(str(n6)))  # <class 'str'>
